package com.wq.config;


import com.wq.interceptors.AuthorizationInterceptor;
import jakarta.annotation.Resource;
import lombok.extern.slf4j.Slf4j;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.servlet.config.annotation.InterceptorRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurationSupport;

import java.util.List;

@Slf4j
@Configuration
public class WebMvcConfig extends WebMvcConfigurationSupport {

    @Resource
    private AuthorizationInterceptor authorizationInterceptor;

    @Override
    protected void addInterceptors(InterceptorRegistry registry) {

        registry.addInterceptor(authorizationInterceptor)
                .addPathPatterns("/**")//拦截所有路径
                .excludePathPatterns(whitelist)//放在这里面的路径不拦截
        ;

    }

    private final List<String> whitelist = List.of(
            "/",
            "/user/login",
            "/user/getCode",
            "/doc.html",
            "/webjars/**",
            "/v3/api-docs/**",
            "/home",
            "/index/**",
            "/stream",
            "/user/register",
            "/user/findPwd",
            "/activity/upload"
    );



}
